public class PalindromesCount {
	public int count(String A, String B) {
		int answer = 0;
        int lena=A.length();
        if(palindromeornot(A+B))answer++;
        if(palindromeornot(B+A))answer++;
        for(int i=0;i<lena-1;i++){
        	String cur=A.substring(0, i+1)+B+A.substring(i+1,lena);
        	if(palindromeornot(cur))answer++;
        }
        return answer;
	}

	private boolean palindromeornot(String str) {
		char[] aaa = str.toCharArray();
		int len = aaa.length;
		for (int i = 0; i < len; i++) {
			if (aaa[i] == aaa[len - 1 - i])
				continue;
			else
				return false;
		}
		System.out.println(str);
		return true;
	}

	// BEGIN CUT HERE
	public static void main(String[] args) {
		if (args.length == 0) {
			PalindromesCountHarness.run_test(-1);
		} else {
			for (int i = 0; i < args.length; ++i)
				PalindromesCountHarness.run_test(Integer.valueOf(args[i]));
		}
	}
	// END CUT HERE
}

// BEGIN CUT HERE
class PalindromesCountHarness {
	public static void run_test(int casenum) {
		if (casenum != -1) {
			if (runTestCase(casenum) == -1)
				System.err.println("Illegal input! Test case " + casenum
						+ " does not exist.");
			return;
		}

		int correct = 0, total = 0;
		for (int i = 0;; ++i) {
			int x = runTestCase(i);
			if (x == -1) {
				if (i >= 100)
					break;
				continue;
			}
			correct += x;
			++total;
		}

		if (total == 0) {
			System.err.println("No test cases run.");
		} else if (correct < total) {
			System.err.println("Some cases FAILED (passed " + correct + " of "
					+ total + ").");
		} else {
			System.err.println("All " + total + " tests passed!");
		}
	}

	static boolean compareOutput(int expected, int result) {
		return expected == result;
	}

	static String formatResult(int res) {
		return String.format("%d", res);
	}

	static int verifyCase(int casenum, int expected, int received) {
		System.err.print("Example " + casenum + "... ");
		if (compareOutput(expected, received)) {
			System.err.println("PASSED");
			return 1;
		} else {
			System.err.println("FAILED");
			System.err.println("    Expected: " + formatResult(expected));
			System.err.println("    Received: " + formatResult(received));
			return 0;
		}
	}

	static int runTestCase(int casenum) {
		switch (casenum) {
		case 0: {
			String A = "aba";
			String B = "b";
			int expected__ = 2;

			return verifyCase(casenum, expected__, new PalindromesCount()
					.count(A, B));
		}
		case 1: {
			String A = "aa";
			String B = "a";
			int expected__ = 3;

			return verifyCase(casenum, expected__, new PalindromesCount()
					.count(A, B));
		}
		case 2: {
			String A = "aca";
			String B = "bb";
			int expected__ = 0;

			return verifyCase(casenum, expected__, new PalindromesCount()
					.count(A, B));
		}
		case 3: {
			String A = "abba";
			String B = "abba";
			int expected__ = 3;

			return verifyCase(casenum, expected__, new PalindromesCount()
					.count(A, B));
		}
		case 4: {
			String A = "topcoder";
			String B = "coder";
			int expected__ = 0;

			return verifyCase(casenum, expected__, new PalindromesCount()
					.count(A, B));
		}

			// custom cases

			/*
			 * case 5: { String A = ; String B = ; int expected__ = ;
			 * 
			 * return verifyCase(casenum, expected__, new
			 * PalindromesCount().count(A, B)); }
			 */
			/*
			 * case 6: { String A = ; String B = ; int expected__ = ;
			 * 
			 * return verifyCase(casenum, expected__, new
			 * PalindromesCount().count(A, B)); }
			 */
			/*
			 * case 7: { String A = ; String B = ; int expected__ = ;
			 * 
			 * return verifyCase(casenum, expected__, new
			 * PalindromesCount().count(A, B)); }
			 */
		default:
			return -1;
		}
	}
}

// END CUT HERE
